package org.wattdepot.cli.command;

import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.wattdepot.cli.processor.CommandLineInterface;
import static org.junit.Assert.assertTrue;

/**
 * PowerStats command test case, evaluates command against known values.
 * 
 * @author Bao Huy Ung, Edward Meyer
 */
public class TestPowerStats extends CommandLineInterface {

  /**
   * Tests if command Powerstats return valid known values.
   */
  @Test
  public void testPower() {

    List<String> args = new ArrayList<String>();

    // checker values for each of the statistics returned by command
    boolean powerCheckMax = false;
    boolean powerCheckMin = false;
    boolean powerCheckAvg = false;

    // add command to be taken by cli
    args.add("powerstats");
    args.add("generated");
    args.add("SIM_WAIAU_8");
    args.add("day");
    args.add("2009-11-15");
    args.add("sampling-interval");
    args.add("30");
    args.add("statistic");
    args.add("max");

    PowerStats power = new PowerStats();
    String testOut = power.doCommand(args);

    // known max value test
    if (testOut.equalsIgnoreCase("8.8E7")) {
      powerCheckMax = true;
    }

    args.set(8, "min");
    args.set(2, "SIM_WAIAU");
    testOut = power.doCommand(args);

    // known min value test
    if (testOut.equalsIgnoreCase("1.16E8")) {
      powerCheckMin = true;
    }

    args.set(8, "average");
    args.set(2, "SIM_WAIAU_8");
    testOut = power.doCommand(args);

    // known average value test
    if (testOut.equalsIgnoreCase("7.152083333333333E7")) {
      powerCheckAvg = true;
    }

    System.out.println("Sampling known value Source: "
        + "SIM_WAIAU_8 2009-11-15 30 minute sampling-interval max");
    assertTrue("Check SIM_WAIAU_8 max on 2009-11-15", powerCheckMax);

    System.out.println("Sampling known value Source: "
        + "SIM_WAIAU 2009-11-15 30 minute sampling-interval min");
    assertTrue("Check SIM_WAIAU min on 2009-11-15", powerCheckMin);

    System.out.println("Sampling known value Srouce: "
        + "SIM_WAIAU_8 2009-11-15 30 minute sampling-interval average");
    assertTrue("Check SIM_WAIAU_8 average on 2009-11-15", powerCheckAvg);

  }

}